<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：首页统计
-->

<template>
    <Card :bordered="false" style="height:430px;">
        <p slot="title">
         	<Icon type="ios-pulse" style="color:#07a1be;font-size: 18px;"/>           	
        	<span style="padding-left:2px;color:#333333;font-size: 14px;font-weight: normal;">登记统计二</span>
        </p>
        <div style="width:100%;float:left;text-align: center;" align="center">
        	<div ref="static2" style="width:100%;min-width: 600px; float:left;height:330px;"></div>
        </div>
    </Card>
</template>

<script>
	import Highcharts from 'highcharts'
	require('highcharts/modules/exporting')(Highcharts);
	export default {
		name:"homepie",
		props: {
    		aged:{
    			type: Array
    		},
    		camlist:{
    			type: Array
    		}
    	},
		components: {
		},
		mounted(){
		 
		},
		methods: {
		    drawLine(){
		    	var aged=this.aged;
		    	var camlist=this.camlist;
		    	
		    	var carr=[];
		     	for(var i=0;i<camlist.length;i++){
		     		carr.push(camlist[i].CSNAME);
		     	}

				var series=[];
				var zsarr=[];
				for(var i=0;i<aged.length;i++){
					
					var countall=0;
					var agelist=aged[i].agelist;
					var agearr=[];
					for(var m=0;m<agelist.length;m++){
						if(agelist[m].COALL){
							agearr.push(agelist[m].COALL);
							countall=parseInt(countall)+parseInt(agelist[m].COALL);
						}else{
							agearr.push(0);
						}
					}
					var age={
						type: 'column',
						name: aged[i].AGE+"岁",
						data: agearr
					}
					series.push(age);
					
					
					var zage={
						name: aged[i].AGE+"岁",
						y: countall,
						color: Highcharts.getOptions().colors[i]
					}
					zsarr.push(zage);
					
				}

		     	var agepie={
					type: 'pie',
					name: '年龄总算统计',
					data: zsarr,
					center: [50, 20],
					size: 100,
					showInLegend: false,
					dataLabels: {
						enabled: false
					}
				}
		     	series.push(agepie);
		     	
		    	var chart = Highcharts.chart(this.$refs.static2, {
					title: {
						text: '年龄登记统计表'
					},
					xAxis: {
						categories: carr
					},
					yAxis: {
				        min: 0,
				        title: {
				            text: '人数'
				        }
				    },
				    lang:{ 
						downloadJPEG: "下载JPEG 图片",  
						downloadPDF: "下载PDF文档"  ,
						downloadPNG: "下载PNG 图片",
						downloadSVG: "下载SVG 矢量图" , 
						exportButtonTitle: "导出图片"  ,
				    },  
					plotOptions: {
						series: {
							stacking: 'normal'
						}
					},
					labels: {
						items: [{
							html: '年龄登记统计',
							style: {
								left: '100px',
								top: '5px',
								color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
							}
						}]
					},
					series:series
				});
		    }
		},
		watch:{
			aged(news,olds){
				if(news){
					this.drawLine();
				}
			}
		},
	}
</script>

<style>
</style>



